﻿#pragma once

#include "../../MirControls/MirImageControl.h"
#include "../../MirControls/MirButton.h"
#include "../../MirControls/MirLabel.h"
#include "../../../Shared/Data/Notice.h"
#include "../../Settings.h"
#include <string>
#include <vector>
#include <cmath>
#include <any>
#include "../../../stringhelper.h"

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirSounds;
using namespace Shared;

namespace Client::MirScenes::Dialogs
{
    class NoticeDialog final : public MirImageControl
    {
    public:
        static Regex *C;
        static Regex *L;

        MirButton *CloseButton, *UpButton, *DownButton, *PositionBar, *OkButton;
        std::vector<MirLabel*> TextLabel;
        std::vector<MirLabel*> TextButtons;
        MirImageControl *TitleLabel;
        MirLabel *NameLabel;

        Notice *Notice = new Notice();

    private:
        Font *font = new Font(Settings::FontName, 10.0F);

    public:
        std::vector<std::string> CurrentLines = std::vector<std::string>();
    private:
        int _index = 0;
    public:
        int MaximumLines = 19;

        virtual ~NoticeDialog()
        {
            delete CloseButton;
            delete UpButton;
            delete DownButton;
            delete PositionBar;
            delete OkButton;
            delete TitleLabel;
            delete NameLabel;
            delete Notice;
            delete font;
        }

        NoticeDialog();

    private:
        void PositionBar_OnMoving(std::any sender, MouseEventArgs *e);

        void LoginNoticeDialog_MouseWheel(std::any sender, MouseEventArgs *e);

        void UpdatePositionBar();

    public:
        void Update(Notice *notice);

        void NewText(std::vector<std::string> &lines, bool resetIndex = true);

    private:
        void NewLink(const std::string &text, const std::string &link, Point *p);

        void NewColour(const std::string &text, const std::string &colour, Point *p);
    };
}
